package SV_PATH_INJ;


import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

public class Vulnerable_02 {
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String name = req.getParameter("userName");
        File userDir = new File("userFiles", name);
        File profile = new File(userDir, "profile");
        FileOutputStream stream = new FileOutputStream(profile);
        try {
            createFileWithSensitiveInformation(stream);
        } finally {
            stream.close();
        }
    }

    private void createFileWithSensitiveInformation(FileOutputStream stream) {

    }
}
